package com.example.xyxwebbackend001.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.xyxwebbackend001.model.entity.Likes;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface LikesMapper  extends BaseMapper<Likes> {
    //    统计点赞数量
    @Select({
            "<script>",
            "SELECT COUNT(*) FROM t_likes",
            "WHERE t_post_id IN",
            "<foreach item='id' collection='postIds' open='(' separator=',' close=')'>",
            "#{id}",
            "</foreach>",
            "</script>"
    })
    Integer sumLikesByPostIds(@Param("postIds") List<Integer> postIds);
}

